package com.cyl.manager.pms.controller;

import java.util.List;

import com.cyl.manager.pms.convert.PmsBrandAttentionConvert;
import com.cyl.manager.pms.domain.entity.PmsBrandAttention;
import com.cyl.manager.pms.domain.query.PmsBrandAttentionQuery;
import com.cyl.manager.pms.domain.vo.PmsBrandAttentionVO;
import com.cyl.manager.pms.service.PmsBrandAttentionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
/**
 * 品牌关注Controller
 *
 * @author zcc
 * @date 2025-05-20
 */
@Api(description ="品牌关注接口列表")
@RestController
@RequestMapping("/mall/pmsBrandAttention")
public class PmsBrandAttentionController extends BaseController {
    @Autowired
    private PmsBrandAttentionService service;
    @Autowired
    private PmsBrandAttentionConvert convert;

    @ApiOperation("查询品牌关注列表")
    @PreAuthorize("@ss.hasPermi('mall:pmsBrandAttention:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<PmsBrandAttention>> list(@RequestBody PmsBrandAttentionQuery query, Pageable page) {
        List<PmsBrandAttention> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("导出品牌关注列表")
    @PreAuthorize("@ss.hasPermi('mall:pmsBrandAttention:export')")
    @Log(title = "品牌关注", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public ResponseEntity<String> export(PmsBrandAttentionQuery query) {
        List<PmsBrandAttention> list = service.selectList(query, null);
        ExcelUtil<PmsBrandAttentionVO> util = new ExcelUtil<>(PmsBrandAttentionVO.class);
        return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "品牌关注数据"));
    }

    @ApiOperation("获取品牌关注详细信息")
    @PreAuthorize("@ss.hasPermi('mall:pmsBrandAttention:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<PmsBrandAttention> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增品牌关注")
    @PreAuthorize("@ss.hasPermi('mall:pmsBrandAttention:add')")
    @Log(title = "品牌关注", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody PmsBrandAttention pmsBrandAttention) {
        return ResponseEntity.ok(service.insert(pmsBrandAttention));
    }

    @ApiOperation("修改品牌关注")
    @PreAuthorize("@ss.hasPermi('mall:pmsBrandAttention:edit')")
    @Log(title = "品牌关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody PmsBrandAttention pmsBrandAttention) {
        return ResponseEntity.ok(service.update(pmsBrandAttention));
    }

    @ApiOperation("删除品牌关注")
    @PreAuthorize("@ss.hasPermi('mall:pmsBrandAttention:remove')")
    @Log(title = "品牌关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
